<template>
  <!-- <div>
    <h2>搜索结果页面</h2>
    <p>{{ $route.query.keyword }}</p>
</div> -->
  <div class="search-container">

 <div class="yua">
   <router-link to="/circle">   <van-icon name="arrow-left" class="qwerty"/></router-link> <input
      type="text"
      v-model="searchKeyword"
      placeholder="输入商品名称进行搜索"
      class="search-input"
    /><button class="uio">搜索</button>
 </div>
    <div class="product-list">
      <div v-for="product in filteredProducts" :key="product.id" class="product-item">

        <h3 class="product-name">{{ product.name }}</h3> <span class="product-price"> {{ product.date }}</span><p>{{ product.price }}</p>

      </div>
    </div>
  </div>
</template>

<script>

export default {

  data() {
    return {
      products: [
        { id: 1, name: "急寻:面神经炎的治疗方法",date:"2018-12-18 12:28", price:"周围性神经炎,下巴写的,口齿不清,眼睛闭合不了,右边脸明显动不了"  },
        { id: 2, name: "面神经炎再也不用担心,用这种方法准管用",date:"2018-12-23 19:52", price:"清晨洗脸、漱口时突然发现一侧面颊动作不灵、巴歪斜,病侧面部表情肌完全瘫痪者，前额皱纹消失、眼裂扩大、鼻唇沟平坦、口角下垂，露齿时口角向健侧偏歪。病侧不能作皱额、盛眉、闭目、鼓气和噘嘴等动作。鼓腮和吹口哨.."  },
        { id: 3, name: "面瘫了怎么办?",date:"2018-12-20 10:20", price:"早上发现，侧面部表情肌瘫痪，前额皱纹消失、眼裂扩大、口角下垂，病侧不能作皱额、蹙眉、闭目、鼓气和噘嘴等。"  },
         { id: 4, name: "急寻:面神经炎的治疗方法",date:"2018-12-18 12:28", price:"周围性神经炎,下巴写的,口齿不清,眼睛闭合不了,右边脸明显动不了"  },
        { id: 5, name: "面神经炎再也不用担心,用这种方法准管用",date:"2018-12-23 19:52", price:"清晨洗脸、漱口时突然发现一侧面颊动作不灵、巴歪斜,病侧面部表情肌完全瘫痪者，前额皱纹消失、眼裂扩大、鼻唇沟平坦、口角下垂，露齿时口角向健侧偏歪。病侧不能作皱额、盛眉、闭目、鼓气和噘嘴等动作。鼓腮和吹口哨.."  },
        { id: 6, name: "面瘫了怎么办?",date:"2018-12-20 10:20", price:"早上发现，侧面部表情肌瘫痪，前额皱纹消失、眼裂扩大、口角下垂，病侧不能作皱额、蹙眉、闭目、鼓气和噘嘴等。"  },
        // 可以继续添加更多商品数据
      ],
      searchKeyword: "",
    };
  },

  computed: {
    filteredProducts() {
      if (this.searchKeyword === "") {
        return this.products;
      }
      return this.products.filter((product) => {
        return product.name.toLowerCase().includes(this.searchKeyword.toLowerCase());
      });
    },
  },
};



</script>

<style scoped lang="scss">

.qwerty{
  margin-top: 0.05rem; //.1rem * 0.5 = 0.05rem
  font-size: 0.25rem; //.5rem * 0.5 = 0.25rem
  margin-bottom: 0.075rem; //.15rem * 0.5 = 0.075rem
}
.yua{
  height: 0.5rem; // 1rem * 0.5 = 0.5rem
  display: flex;
      justify-content: space-between;
  border-bottom: 0.05rem solid #ccc; //.1rem * 0.5 = 0.05rem
    align-items: center;
}
.search-container {
  width: 100%;
  margin: 0 auto;
  padding: 10px; // 20px * 0.5 = 10px
  border: 0.5px solid #ccc; // 1px * 0.5 = 0.5px
  border-radius: 2.5px; // 5px * 0.5 = 2.5px
}
.uio{
  border: none;
  background-color: #FFF;
  color: rgb(77, 151, 236);
    width: 0.6rem; // 1.2rem * 0.5 = 0.6rem
    font-size: 0.2rem; //.4rem * 0.5 = 0.2rem
  margin-bottom: 0.1rem; //.2rem * 0.5 = 0.1rem
}
.search-input {
  width: 3.5rem; // 7rem * 0.5 = 3.5rem
  height: 0.25rem; //.5rem * 0.5 = 0.25rem
  padding: 5px; // 10px * 0.5 = 5px
  margin-bottom: 5px; // 10px * 0.5 = 5px
  border: 0.5px solid #ccc; // 1px * 0.5 = 0.5px
  border-radius: 1rem; // 2rem * 0.5 = 1rem
}

.product-list {
  width: 100%;
  list-style: none;
  padding: 0;
  line-height: 0.4rem; //.8rem * 0.5 = 0.4rem
}

.product-item {
  border-bottom: 0.5px solid #ccc; // 1px * 0.5 = 0.5px
  padding: 5px 0; // 10px 0减半
}

.product-name {

  font-weight: bold;
}
</style>
